﻿<shared:PageBase x:Class="Miris.HumanMilkAnalyser.WPF.DataManagementPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:shared="clr-namespace:Miris.HumanMilkAnalyser.WPF.Shared"
      x:Name="CurrentPage"
      mc:Ignorable="d" 
      d:DesignHeight="580" d:DesignWidth="1160"
	  Title="DataManagementPage" Style="{StaticResource DefaultPageStyle}" 
      DataContext="{Binding DataManagement, Source={StaticResource Locator}}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/Storyboard/PageStoryborad.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource NavigationButton}">
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <ScaleTransform ScaleX="0.7" ScaleY="0.7" />
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </Page.Resources>
    <Grid HorizontalAlignment="Center">
        <Grid.ColumnDefinitions>
            <!-- Back Button -->
            <ColumnDefinition Width="Auto" />
            <!-- Main Content -->
            <ColumnDefinition Width="Auto" />
            <!-- Next Button -->
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Button Margin="0,0,30,0" Width="47" Tag="/Skins/Resource/Image/Back.png" Style="{StaticResource OpacityImageButton}" Click="ButtonReturn_Click" />
        <!-- Trasparent effect Background -->
        <Border Grid.Column="1" Style="{StaticResource PageContentContainerBorder}">
            <Border Style="{StaticResource PageContentBackgroundBorder}" />
        </Border>
        <Grid Grid.Column="1" Width="1050" Height="550">
            <Grid.RowDefinitions>
                <!-- Page Title -->
                <RowDefinition Height="55" />
                <!-- Data Management Functions -->
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Text="数据管理" Margin="0,15,40,0" HorizontalAlignment="Center" Style="{StaticResource PageTitleTextBlock}" />
            <Grid Grid.Row="1" Margin="20,0,20,0" Height="500">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Border Margin="0,0,0,15" Style="{StaticResource OperationPortionBorder}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="数据库恢复" Tag="/Skins/Resource/Image/Data-Import.png" Command="{Binding ImportDataSourceCommand}" />
                            <Button Content="数据库备份" Tag="/Skins/Resource/Image/Data-Export.png" Command="{Binding ExportDataSourceCommand}" />
                            <TextBlock Margin="30,0,0,0" VerticalAlignment="Center">
                                <TextBlock.Style>
                                    <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource ImportantInformationTextBlock}">
                                        <Setter Property="Text" Value="*如数据量大时，操作时间会长。" />
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding IsSqlServerCe}" Value="False">
                                                <Setter Property="Text" Value="系统当前正在使用SQL Server数据库，请使用微软官方管理工具进行数据库的导入导出操作。" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                        </StackPanel>
                        <StackPanel Grid.Row="1" Orientation="Horizontal">
                            <StackPanel.Style>
                                <Style TargetType="{x:Type StackPanel}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ExportDataSourceFileName}" Value="">
                                            <Setter Property="Visibility" Value="Hidden" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="数据库已成功导入，且之前系统已自动将当前" VerticalAlignment="Center">
                                <TextBlock.Style>
                                    <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource WhiteTextBlock}">
                                        <Setter Property="Visibility" Value="Collapsed" />
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ImportedDataSourceFile}" Value="True">
                                                <Setter Property="Visibility" Value="Visible" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                            <TextBlock Text="数据成功备份，点击" VerticalAlignment="Center" Style="{StaticResource WhiteTextBlock}" />
                            <Button ToolTip="打开文件夹" Tag="/Skins/Resource/Image/Folder-Open.png" Style="{StaticResource OpacityImageButton}" 
                                Command="{Binding OpenDataSourceFileExportDirectoryCommand}" />
                            <TextBlock Text="{Binding ExportDataSourceFileName, StringFormat={}查看备份文件{0}。}" VerticalAlignment="Center" Style="{StaticResource WhiteTextBlock}" />
                        </StackPanel>
                    </Grid>
                </Border>
                <Border Margin="0,0,0,15" Grid.Row="1" Style="{StaticResource OperationPortionBorder}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="被测者数据导入" Tag="/Skins/Resource/Image/Data-Import.png" Command="{Binding ImportPatientDataCommand}" />
                            <Button Content="被测者数据导出" Tag="/Skins/Resource/Image/Data-Export.png" Command="{Binding ExportPatientDataCommand}" />
                            <Button Content="数据库导出" Tag="/Skins/Resource/Image/CSV-Export.png" Command="{Binding ExportTestReportCommand}" />
                            <Button Content="备份日志导出" Tag="/Skins/Resource/Image/Export.png" Command="{Binding ExportMiniLogCommand}" />
                            <TextBlock Text="*如数据量大时，操作时间会长。" VerticalAlignment="Center" Style="{StaticResource ImportantInformationTextBlock}" />
                        </StackPanel>
                        <TextBlock Grid.Row="1" Text="被测者数据已成功导入" VerticalAlignment="Center">
                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource WhiteTextBlock}">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ImportedPatientDataFile}" Value="True">
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                        <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal">
                            <StackPanel.Style>
                                <Style TargetType="{x:Type StackPanel}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ExportPatientDataFileName}" Value="">
                                            <Setter Property="Visibility" Value="Hidden" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="被测者数据成功导出，点击" VerticalAlignment="Center" Style="{StaticResource WhiteTextBlock}" />
                            <Button ToolTip="打开文件夹" Tag="/Skins/Resource/Image/Folder-Open.png" Style="{StaticResource OpacityImageButton}" 
                                Command="{Binding OpenPatientDataXmlFileExportDirectoryCommand}" />
                            <TextBlock Text="{Binding ExportPatientDataFileName, StringFormat={}查看导出文件{0}。}" VerticalAlignment="Center" Style="{StaticResource WhiteTextBlock}" />
                        </StackPanel>
                    </Grid>
                </Border>
                <Border Grid.Row="2" Style="{StaticResource OperationPortionBorder}">
                    <Grid>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="操作密码 " VerticalAlignment="Center" Style="{StaticResource WhiteTextBlock}" />
                            <PasswordBox x:Name="CleanDataSourcePassword" Width="200" Height="30" FontSize="18" />
                            <Button Content="清除数据库" Tag="/Skins/Resource/Image/Clean.png" Click="ButtonClean_Click" />
                            <TextBlock Grid.Row="1" Text="数据库已成功清空" VerticalAlignment="Center">
                                <TextBlock.Style>
                                    <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource WhiteTextBlock}">
                                        <Setter Property="Visibility" Value="Collapsed" />
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding CleanedDataSource}" Value="True">
                                                <Setter Property="Visibility" Value="Visible" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                        </StackPanel>
                    </Grid>
                </Border>
            </Grid>
        </Grid>
        <Button Grid.Column="2" Margin="30,0,0,0" Width="47" Tag="/Skins/Resource/Image/Next.png" Style="{StaticResource OpacityImageButton}" Visibility="Hidden" />
    </Grid>
</shared:PageBase>
